using BCW;
using I2.Loc;
using UnityEngine;

public class StarterPackRewardUI : MonoBehaviour
{
	private StarterPackReward reward;

	public UILabel titleLabel;

	public UILabel amountLabel;

	public UILabel vipAmountLabel;

	public UISprite cashSprite;

	public UISprite goldSprite;

	public UIBasicSprite productTexture;

	public void Init(StarterPackReward reward)
	{
		productTexture = productTexture.ReplaceForCurrentPlatform();
		this.reward = reward;
		amountLabel.gameObject.SetActive(false);
		cashSprite.gameObject.SetActive(false);
		goldSprite.gameObject.SetActive(false);
		productTexture.gameObject.SetActive(false);
		vipAmountLabel.gameObject.SetActive(false);
		switch (reward.rewardGroup)
		{
		case StarterPackRewardGroup.Cash:
			cashSprite.gameObject.SetActive(true);
			amountLabel.gameObject.SetActive(true);
			amountLabel.text = reward.amount.ToString();
			SetTitle(ScriptLocalization.Get("Marathon/Cash"));
			break;
		case StarterPackRewardGroup.Gold:
			goldSprite.gameObject.SetActive(true);
			amountLabel.gameObject.SetActive(true);
			amountLabel.text = reward.amount.ToString();
			SetTitle(ScriptLocalization.Get("Marathon/Coins"));
			break;
		case StarterPackRewardGroup.Product:
		{
			Product product = reward.GetProduct();
			if (product != null)
			{
				productTexture.gameObject.SetActive(true);
				productTexture.LoadTextureAndAlphaMask("AtlasShopGuns/", product.texture);
				if (reward.amount > 0)
				{
					if (product.subCategoryName == "VipAccount")
					{
						vipAmountLabel.gameObject.SetActive(true);
						vipAmountLabel.text = reward.amount.ToString();
					}
					else
					{
						amountLabel.gameObject.SetActive(true);
						amountLabel.text = reward.amount.ToString();
					}
				}
				SetTitle(ScriptLocalization.Get("Market/" + product.id + "_title"));
			}
			else
			{
				InitAlternative(reward.alternativeReward);
			}
			break;
		}
		}
	}

	private void InitAlternative(Reward alternativeReward)
	{
		amountLabel.gameObject.SetActive(false);
		cashSprite.gameObject.SetActive(false);
		goldSprite.gameObject.SetActive(false);
		productTexture.gameObject.SetActive(false);
		switch (alternativeReward.rewardGroup)
		{
		case RewardGroups.Cash:
			cashSprite.gameObject.SetActive(true);
			amountLabel.gameObject.SetActive(true);
			amountLabel.text = alternativeReward.rewardAmount.ToString();
			SetTitle(string.Empty);
			break;
		case RewardGroups.Coins:
			goldSprite.gameObject.SetActive(true);
			amountLabel.gameObject.SetActive(true);
			amountLabel.text = alternativeReward.rewardAmount.ToString();
			SetTitle(string.Empty);
			break;
		case RewardGroups.Product:
			productTexture.gameObject.SetActive(true);
			productTexture.LoadTextureAndAlphaMask("AtlasShopGuns/", alternativeReward.rewerdID);
			SetTitle(ScriptLocalization.Get("Market/" + alternativeReward.rewerdID + "_title"));
			break;
		case RewardGroups.ProductConsumable:
			productTexture.gameObject.SetActive(true);
			productTexture.LoadTextureAndAlphaMask("AtlasShopGuns/", alternativeReward.rewerdID);
			SetTitle(ScriptLocalization.Get("Market/" + alternativeReward.rewerdID + "_title"));
			break;
		}
	}

	private void SetTitle(string title)
	{
		if (titleLabel != null)
		{
			titleLabel.text = title;
		}
		else
		{
			titleLabel.text = string.Empty;
		}
	}
}
